<html>
<head><meta charset="utf-8"><title>Avoid parsing items to determine if they are deprecated · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Avoid.20parsing.20items.20to.20determine.20if.20they.20are.20deprecated.html">Avoid parsing items to determine if they are deprecated</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="179845862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Avoid%20parsing%20items%20to%20determine%20if%20they%20are%20deprecated/near/179845862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Martin Asquino <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Avoid.20parsing.20items.20to.20determine.20if.20they.20are.20deprecated.html#179845862">(Nov 04 2019 at 16:00)</a>:</h4>
<p>I've been looking at <a href="https://github.com/rust-analyzer/rust-analyzer/issues/2167" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/2167">https://github.com/rust-analyzer/rust-analyzer/issues/2167</a> and I think I've got something going. Would appreciate some more experienced eyes to look at how the implementation looks right now.</p>
<p>I've opened a PR on my own fork while I work on it so you can look at the diffs without me opening a PR in rust-analyzer/rust-analyzer: <a href="https://github.com/martskins/rust-analyzer/pull/2" target="_blank" title="https://github.com/martskins/rust-analyzer/pull/2">https://github.com/martskins/rust-analyzer/pull/2</a> The thing that I'm most worried about is that massive match I have in <code>attributes_query</code>, but other than introducing a macro for that I'm not sure how to solve that.</p>
<p>Also, please disregard the commented code, I'll remove that once this is considered done.</p>



<a name="179847475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Avoid%20parsing%20items%20to%20determine%20if%20they%20are%20deprecated/near/179847475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Avoid.20parsing.20items.20to.20determine.20if.20they.20are.20deprecated.html#179847475">(Nov 04 2019 at 16:16)</a>:</h4>
<p>Will take a look shortly! One thing I've realised is that I haven't shown how to test hypothesis that "deprecation tags cause parsing". See <a href="https://github.com/matklad/rust-analyzer/commit/bcf17f26401501a7350e706ab8a776779dcfc8fa" target="_blank" title="https://github.com/matklad/rust-analyzer/commit/bcf17f26401501a7350e706ab8a776779dcfc8fa">https://github.com/matklad/rust-analyzer/commit/bcf17f26401501a7350e706ab8a776779dcfc8fa</a> for an example how to do it</p>



<a name="179847578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Avoid%20parsing%20items%20to%20determine%20if%20they%20are%20deprecated/near/179847578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Avoid.20parsing.20items.20to.20determine.20if.20they.20are.20deprecated.html#179847578">(Nov 04 2019 at 16:17)</a>:</h4>
<p><code>Scope</code> thing is a small debug helper which allows one to delimit dynamic scope (for exapmle, things happening during completion)</p>



<a name="179847656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Avoid%20parsing%20items%20to%20determine%20if%20they%20are%20deprecated/near/179847656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Avoid.20parsing.20items.20to.20determine.20if.20they.20are.20deprecated.html#179847656">(Nov 04 2019 at 16:18)</a>:</h4>
<p><code>print_backtrace</code> can then be used to figure out why did you end up parsing things</p>



<a name="179847709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Avoid%20parsing%20items%20to%20determine%20if%20they%20are%20deprecated/near/179847709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Martin Asquino <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Avoid.20parsing.20items.20to.20determine.20if.20they.20are.20deprecated.html#179847709">(Nov 04 2019 at 16:19)</a>:</h4>
<p>oh, nice! will look into it! thanks!</p>



<a name="179848354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Avoid%20parsing%20items%20to%20determine%20if%20they%20are%20deprecated/near/179848354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Avoid.20parsing.20items.20to.20determine.20if.20they.20are.20deprecated.html#179848354">(Nov 04 2019 at 16:25)</a>:</h4>
<p>Yeah, that commit is roughly how it should be done! Don't worry about that gigantic match --- that's a pretty common pattern for rust-analyzer, the one for docs is similar. Though, you might slightly condence it, if you move hygiene bit to before the `match</p>



<a name="179850239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Avoid%20parsing%20items%20to%20determine%20if%20they%20are%20deprecated/near/179850239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Avoid.20parsing.20items.20to.20determine.20if.20they.20are.20deprecated.html#179850239">(Nov 04 2019 at 16:43)</a>:</h4>
<p><span class="user-mention" data-user-id="203366">@Jeremy Kolb</span> this zulip thread :)</p>



<a name="179850356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Avoid%20parsing%20items%20to%20determine%20if%20they%20are%20deprecated/near/179850356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Avoid.20parsing.20items.20to.20determine.20if.20they.20are.20deprecated.html#179850356">(Nov 04 2019 at 16:44)</a>:</h4>
<p>I think, once this ground work with attrs done, we should:</p>
<ul>
<li>extend it to also handle inner attributes</li>
<li>remove hir documentation infrastructure in favor of deshugaring <code>/// foo</code> into <code>#[doc = "fooo"]</code></li>
</ul>



<a name="179852093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Avoid%20parsing%20items%20to%20determine%20if%20they%20are%20deprecated/near/179852093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Martin Asquino <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Avoid.20parsing.20items.20to.20determine.20if.20they.20are.20deprecated.html#179852093">(Nov 04 2019 at 17:02)</a>:</h4>
<p>That was actually my original idea (moving hygiene before match), but I couldn't figure out how to get <code>file_id</code> from <code>AttrDef</code>. In any case, I managed to clean it up a little and reduce  the repetition only to two places. Could be better, but it's a start <span aria-label="smiley" class="emoji emoji-1f603" role="img" title="smiley">:smiley:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>